
// RefreeRetrievalDlg.h : header file
//

#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include "Video/VideoAna.h"
#include "Retriever/Retriever.h"
#include "../PatchCluster/FeatureExtract/HistFeature.h"
#include "picctrl.h"

// CRefreeRetrievalDlg dialog
class CRefreeRetrievalDlg : public CDialog
{
	CImageList		m_imglstFrames;
	CVideoAna		m_vidAnalysis;
	int				m_iFrameCount;
	CRetriever		m_vidRetriever;
	CCodeBook*		m_codeBook;
	CHistFeature*	m_histExtractor;
	CArray<HBITMAP> m_arrKeyFrames;
	char			m_sSIFTKmeansModel[MAX_PATH];
	char			m_sSIFTSVMModel[MAX_PATH];

	BOOL ReadParams(CString& sVideoFile, CString& sClusterModelFile,
		double& dClusterThreshold, int& iPatchSize, PatchMode& patchMode,
		int& regionThreshold, int& iThreadCount);
	void DeleteHBITMAPs(CArray<HBITMAP> & arr);

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();

	DECLARE_MESSAGE_MAP()

public:
	CRefreeRetrievalDlg(CWnd* pParent = NULL);	// standard constructor
	~CRefreeRetrievalDlg();
	enum { IDD = IDD_REFREERETRIEVAL_DIALOG };

	CEdit m_txtInputVideo;
	CButton m_btnInputVideo;
	CEdit m_txtClusterModel;
	CButton m_btnClusterModel;
	CListCtrl m_lstFrames;
	CEdit m_txtClusterThreshold;
	CEdit m_txtPatchSize;
	CSpinButtonCtrl m_spinPatchSize;
	CComboBox m_cmbPatchMode;
	CEdit m_txtRegionThreshold;
	CSpinButtonCtrl m_spinRegionThreshold;
	CPicCtrl m_picVideo;
	CButton m_btnPause;
	CButton m_btnStart;
	CButton m_btnExit;
	CStatic m_lblFrames;
	CSpinButtonCtrl m_spinThreadCount;
	CEdit m_txtThreadCount;
	CEdit m_txtSIFTKmeansModel;
	CEdit m_txtSIFTSVMModel;

	void EmptyImgList(CImageList& imgList);

	afx_msg void OnBnClickedBtninputvideo();
	afx_msg void OnBnClickedBtnclustermodel();
	afx_msg void OnBnClickedOk();
	LRESULT OnVideoAnaGraphNotify(WPARAM wParam, LPARAM lParam);
	LRESULT OnVideoAnaUserAnalysis(WPARAM wParam, LPARAM lParam);
	LRESULT OnRetrieverMessage(WPARAM wParam, LPARAM lParam);
	afx_msg void OnBnClickedCancel();
	afx_msg void OnBnClickedBtnpause();
	afx_msg void OnLvnItemActivateLstframes(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnBnClickedBtnsiftkmeansmodel();
	afx_msg void OnBnClickedBtnsiftsvmmodel();
};
